/**
 * @TestTick.as
 * 
 * @author sodaChen mail:sujun10#21cn.com
 * @version 1.0
 * <br>Copyright (C), 2010-2015 asFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:ASFrame
 * <br>Date:2015-10-20
 */
package
{
	import com.asframe.tick.ITick;
	
	import flash.display.Sprite;
	import flash.utils.getTimer;
	
	/**
	 * 测试心跳的fun和心跳接口的性能方案。fun方便，接口清晰
	 * @author sodaChen
	 * Date:2015-10-20
	 */
	public class TestTick extends Sprite
	{
		private var tickList:Vector.<ITick>;
		private var tickFun:Vector.<Function>;
		public function TestTick()
		{
			super();
			
			tickList = new Vector.<ITick>();
			tickFun = new Vector.<Function>();
			var tick:TickBaisc = new TickBaisc();
			
			for (var i:int = 0; i < 10000; i++) 
			{
				tickList.push(tick);
				tickFun.push(tick.tick);
			}
			
			var time:int = getTimer();
			for (var j:int = 0; j < 10000; j++) 
			{
				tickList[j].tick();
			}
			trace("接口花费时间:" + (getTimer() - time));
			time = getTimer();
			for (var k:int = 0; k < 10000; k++) 
			{
				tickFun[k]();
			}
			trace("方法花费时间:" + (getTimer() - time));
			//两者消耗的时间基本相同，可以看出，怎么方便怎么用，tick是方便外部辨认，但是需要实现接口，也是个麻烦。直接使用方法是最方便的
		}
	}
}
import com.asframe.tick.ITick;

class TickBaisc implements ITick
{
	private var index:int = 0;
	public function tick():void
	{
//		index++;
	}
}